package com.erps.sys.rest;

import java.util.Date;

import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.StringEx;
import com.erps.db.DBManager;

public class ErspResRequestRest {
	public int Count(int iStartDay, int iFinishDay) {
		String cStartDay = String.valueOf(iStartDay) + "000000";
		String cFinishDay = String.valueOf(iFinishDay) + "999999";
		return Count(cStartDay, cFinishDay);
	}

	public int Count(String cStartDay, String cFinishDay) {
		StringBuffer sql = new StringBuffer();
		sql.append("select count(1) from ersp_res_request ");
		sql.append(" where create_time>'" + cStartDay + "'");
		sql.append(" and create_time<'" + cFinishDay + "'");
		return StringEx.getInt(DBManager.GetStrValue(sql.toString()));
	}

	public int Count() {
		Date vDate = new Date();
		String cStartDay;
		String cFinishDay;
		int iMonth = vDate.getMonth();
		if (iMonth > 6) {
			cStartDay = DateUtils.getDateStr(new Date(), "yyyy") + "0000000000";
			cFinishDay = DateUtils.getDateStr(new Date(), "yyyy") + "0800000000";
		} else {
			String cYear = DateUtils.getDateStr(new Date(), "yyyy");
			cFinishDay = cYear + "0000000000";
			int iYear = StringEx.getInt(cYear) - 1;
			cStartDay = String.valueOf(iYear) + "0800000000";
		}
		return Count(cStartDay, cFinishDay);
	}
}